import Vue from "vue";
import VueRouter from "vue-router";

//登录
import Login from "../views/Login.vue"

import Home from "../views/Home.vue";
//首页
import Index from "../views/Index.vue";

/***********************************收益进账**************************************** */
//订单查询
import Order from "../views/Order.vue";
//营业额查询
import TurnoverList from "../views/TurnoverList.vue"

/***********************************机器管理**************************************** */
//我得设备
import Myequipments from "../views/Myequipments.vue"

/***********************************广告管理**************************************** */
import AD from "../views/AD/Ad.vue"
import AD_Detail from "../views/AD/Detail.vue"

//用户
import User from "../views/User.vue"

Vue.use(VueRouter);

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: "/",
    component: Home,
    children:[
      {
        path:'/',
        name:'Index',
        component:Index,
        meta: {
          islogin: true
        }
      },
      {
        path:'order',
        name:'Order',
        component:Order,
        meta: {
          islogin: true
        }
      },
      {
        path:'turnoverlist',
        name:'TurnoverList',
        component:TurnoverList,
        meta:{
          isLogin:true
        }
      },
      {
        path:'user',
        name:'User',
        component:User,
        meta: {
          islogin: true
        }
      },
      {
        path:'myequipments',
        name:'Myequipments',
        component:Myequipments,
        meta:{
          islogin:true
        }
      },
      {
        path:'ad',
        name:'AD',
        component:AD,
        meta:{
          islogin:true
        }
      },
      {
        path:'ad/detail',
        name:'AD_Detail',
        component:AD_Detail,
        meta:{
          islogin:true
        }
      }
    ]
  },
  {
    path:'/login',
    name:'Login',
    component:Login
  }
];

const router = new VueRouter({
  mode: "history",//history
  base: process.env.BASE_URL,
  routes
});


export default router;
